#include "primitive.h"

#include "shape.h"
#include "material.h"

namespace csupbr {

    GeoPrimitive::GeoPrimitive(std::shared_ptr<Shape> shape,
                               std::shared_ptr<Material> material)
        : shape(shape), material(material) {}

    bool GeoPrimitive::intersect(const Ray &ray, Intersection &isct) const {
        if (shape->intersect(ray, isct)) {
            isct.primitive = const_cast<GeoPrimitive*>(this);
            return true;
        }
        return false;
    }

    bool GeoPrimitive::intersectP(const Ray &ray, bool blend_test) const {
        return shape->intersectP(ray, blend_test);
    }

    BBox3f GeoPrimitive::getBBox() const {
        return shape->getBBox();
    }

}